import java.awt.Color;
import java.awt.Image;
import java.io.File;
import java.net.URL;
import java.util.List;
import java.util.ResourceBundle;

import javax.annotation.Resources;
import javax.imageio.ImageIO;

import lib.Board;
import lib.Cell;
import lib.DefaultBoardRenderProperties;

public class OthelloBoardRenderProperties extends DefaultBoardRenderProperties {

	Image backgroundImage ;
	Image whiteImage ;
	Image blackImage ;

	public OthelloBoardRenderProperties () {
		try {
			backgroundImage = ImageIO.read (getClass().getResource("img/ground.png")) ;
			whiteImage = ImageIO.read (getClass().getResource("img/white.png")) ;
			blackImage = ImageIO.read (getClass().getResource("img/black.png")) ;
		} catch (Exception e) {
			e.printStackTrace() ;
		}
	}

	public Image getBackgroundImage () {
		return backgroundImage ;
	}

	@SuppressWarnings("rawtypes")
	public Image getCellImage (Board board, int row, int col) {
		OthelloBoard othelloBoard = (OthelloBoard) board ;
		Object cellState = othelloBoard.getCellState(row, col) ;
		if (cellState instanceof OthelloCellState) {
			OthelloCellState sCellState = (OthelloCellState) cellState ;
			if (sCellState.getPlayer() == Player.WHITE) {
				return whiteImage ;
			} else if (sCellState.getPlayer() == Player.BLACK) {
				return blackImage ;
			}
		}
		return null ;
	}
	
	@SuppressWarnings("rawtypes")
	public Color getCellBorderColor (Board board, int row, int col) {
		OthelloBoard othelloBoard = (OthelloBoard) board ;
		List<Cell> validMoveList = othelloBoard.getMoves() ;
		if (validMoveList != null) {
			if (validMoveList.contains(new Cell(row, col))) {
				return Color.yellow ;
			}
		}
		return null;
	}
}
